﻿using System;
using System.Diagnostics;
using Xunit;

namespace MyDemo.ExamSubject
{
    /// <summary>
    /// 面试题2
    /// </summary>
    public class Subject2
    {
        [Fact]
        public void Test()
        {
            B b = new B();
            A a = new A();
            a.Fun2(b);
            b.Fun2(a);
        }

        public class A 
        {
            public virtual void Fun1(int i)
            {
                Debug.WriteLine(i);
            }

            public void Fun2(A a)
            {
                a.Fun1(1);
                Fun1(5);
            }
        }

        public class B : A
        {
            public override void Fun1(int i)
            {
                base.Fun1(i + 1);
            }
        }
    }

}